-
Notifications
You must be signed in to change notification settings - Fork 17
feat: preserve @ts-ignore
for generated types
#110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Note to self: remove |
This is kinda terrifying to need; what's the rationale for doing this? There's basically no warranty for any ts-ignore remaining stable over versions. |
Using ts-ignore here really is a hack. I suppose a better solution would be something like microsoft/TypeScript#31894 where we can tell TypeScript "this type doesn't currently exist but it's okay". Basically, we just need a way to tell TypeScript we know what we're doing when it errors on types we will generate. |
Indeed — I would love to come up with a better solution! If you have any suggestions I'm all ears. Essentially the problem is this: in addition to the things exposed from Since we can't expose types for I'd argue that these use cases are legitimate but I definitely realise that we are colouring outside the lines here. If there's a preferable way to accomplish all this (without a DX downgrade for our users) then I would love to know what it is! |
In general, I feel like generating code directly into the user's But, I can understand that's not a shared opinion. It's just that |
That's the DX downgrade that we're trying to avoid!
That's exactly what we're doing — the |
This PR makes a change that preserves
/** @ts-ignore */
comments to correctly ignore imported generated types that can't be resolved during compilation. It also tries to preserve the jsdoc type imports to modules that can't be resolved. The sourcemaps don't work for the imports in both of these situations, but shouldn't matter since ctrl+clicking them wouldn't lead anywhere anyway.Typically, comments such as
// @ts-ignore
are not preserved in the emitted declarations, with no way to turn this on/off microsoft/TypeScript#38628However, multi-line comments that look like jsdoc are preserved
/** @ts-ignore */
.